<?php 
class ProductController extends Controller{
	//商品模型对象
	private $db;
	//商品ID
	private $goods_gid;

	public function __init(){
		//商品模型
		$this->db=K('Product');
	}

	public function manage(){
		if(IS_POST){
			if($this->db->addProduct()){				
				$this->success('货品添加成功','Goods/index');
			}else{
				$this->error($this->db->error);
			}
		}else{
			//当前商品的属性名
			$attr=$this->db->getAttr($this->goods_gid);
			// p($attr);
			//分配属性信息
			$this->assign('attr',$attr);
			//获取已添加的货品信息
			$product=$this->db->getProduct($this->goods_gid);
			// p($product);exit;
			$this->assign('product',$product);
			$this->display();
		}
	}

	public function delProduct(){
		if($this->db->delProduct()){
			$this->success('货品删除成功','Goods/index');
		}else{
			$this->error($this->db->error);
		}
	}


}


?>